package com.dt76.smallloanbackenduser.controller.hzp;

import com.dt76.smallloanbackenduser.remote.hzp.HContractTemplateRemote;
import com.dt76.smallloanbackenduser.utils.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
@RequestMapping("/hzp")
public class HContractTemplateContrller {
    //远程服务
    @Autowired
    private HContractTemplateRemote hContractTemplateRemote;

    @RequestMapping("/contractTemplate")
    public String qryAllHCT(Model model) {
        model.addAttribute("hctList", hContractTemplateRemote.qryAllHCT());
        System.out.println("调用远程服务器成功");
        System.out.println(hContractTemplateRemote.qryAllHCT());
        return "pages/hzp/contractTemplate";
    }
    @RequestMapping("/pageHCT/pageList/{page}")
    public String qryPageHCT(Model model, @PathVariable Integer page){
        if (page<=0){
            page=1;
        }
        Page page1=hContractTemplateRemote.qryPageHCT(page,3);
        model.addAttribute("hctList",page1.getRows());
        model.addAttribute("indexPage",page1.getPageIndex());
        model.addAttribute("totalPage",page1.getTotalPageCount());
        return "pages/hzp/contractTemplate";
    }
}